package oj;

public class LC914 {
    public boolean hasGroupsSizeX(int[] deck) {
        int n=deck.length;
        if(n==1){
            return false;
        }
        int[] arr=new int[10000];
        for(int i=0;i<deck.length;i++){
            arr[deck[i]]++;
        }

        int g=-1;
        for(int i=0;i<10000;i++){
            if(arr[i]==0){
                continue;
            }
            if(g==-1){
                g=arr[i];
            }else{
                g=num(g,arr[i]);
            }
        }
        return g>=2;
    }
    private static int num(int x,int y){
        return x==0?y:num(y%x,x);
    }
}